package com.mijie.homi.common.protocol;

import java.nio.charset.Charset;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

public class HomiProtocolCodecFactory implements ProtocolCodecFactory{

	private Charset charset;
	private ProtocolDecoder decoder;
	private ProtocolEncoder encoder;
	
	public HomiProtocolCodecFactory(Charset charset){
		this.charset = charset;
		decoder = new HomiProtocolDecoder(charset);
		encoder = new HomiProtocolEncoder(charset);
	}

	public ProtocolEncoder getEncoder(IoSession session) throws Exception {
		return encoder;
	}

	public ProtocolDecoder getDecoder(IoSession session) throws Exception {
		return decoder;
	}
	
	
}
